package com.pagepub.expo.manager;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.flex.remoting.RemotingDestination;
import org.springframework.flex.remoting.RemotingInclude;
import org.springframework.jdbc.core.namedparam.BeanPropertySqlParameterSource;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.jdbc.core.namedparam.SqlParameterSource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.pagepub.expo.dao.CorpCatalogDao;
import com.pagepub.expo.dao.UserRoleDao;
import com.pagepub.expo.entity.CorpCatalog;
import com.pagepub.expo.entity.IdName;
import com.pagepub.expo.entity.UserRole;

@Service
@Transactional
@RemotingDestination(channels = { "my-amf", "my-secure-amf" })
public class UserRoleMng {

	@Autowired
	private UserRoleDao userRoleDao;

	@RemotingInclude
	@Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
	public List<UserRole> findAllByUser(Long userId) {
		return userRoleDao.findAllByUser(userId);
	}

	@RemotingInclude
	@Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
	public List<UserRole> findAllByRole(Long roleId) {
		return userRoleDao.findAllByRole(roleId);
	}

	@RemotingInclude
	@Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
	public void insert(UserRole bean) {
		userRoleDao.insert(bean);
	}

	@RemotingInclude
	@Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
	public void deleteByUser(Long id) {
		userRoleDao.deleteByUser(id);
	}
	
	@RemotingInclude
	@Transactional(propagation = Propagation.NOT_SUPPORTED, readOnly = true)
	public void deleteByRole(Long id) {
		userRoleDao.deleteByRole(id);
	}
}
